' // ***************************************************************************
' // 
' // Copyright (c) Microsoft Corporation.  All rights reserved.
' // 
' // Microsoft Deployment Toolkit Solution Accelerator
' //
' // File:      Summary_scripts.vbs
' // 
' // Version:   6.0.2223.0
' // 
' // Purpose:   Scripts to initialize and validate summary wizard
' // 
' // ***************************************************************************

Option Explicit

Dim iErrors
Dim iWarnings
Dim sBuffer

Function InitializeSummary

	Dim sSystemDrive
	Dim oDrive
	Dim sArchiveDir
	Dim oResults
	Dim iRetVal
	Dim sDeploymentType


	' Get the deployment system drive

	sSystemDrive = "C:"
	For each oDrive in oFSO.Drives
		If oDrive.DriveType = 2 then
			If oDrive.IsReady Then
				If (oFSO.FolderExists(oDrive.DriveLetter & ":\Windows") or oFSO.FolderExists(oDrive.DriveLetter & ":\Winnt")) and oDrive.DriveLetter<>"X" then

					sSystemDrive = oDrive.DriveLetter & ":"
					Exit For

				End if
			End If
		End if
	Next


	' Figure out what directory to use

	If oEnv("SystemDrive") = "X:" then
		sArchiveDir = sSystemDrive & "\WINDOWS\TEMP"
	Else
		If sSystemDrive = oEnv("SystemDrive") then
			sArchiveDir = oEnv("SystemRoot") & "\TEMP"
		Else
			sArchiveDir = sSystemDrive & "\WINDOWS\TEMP"
		End if
	End if


	' Load the results

	Set oResults = oUtility.CreateXMLDOMObjectEx(sArchiveDir & "\DeploymentLogs\Results.xml")
	iErrors = CInt(oUtility.SelectSingleNodeString(oResults, "//Errors"))
	iWarnings = CInt(oUtility.SelectSingleNodeString(oResults, "//Warnings"))
	sBuffer = oUtility.SelectSingleNodeString(oResults, "//Messages")
	iRetVal = CLng(oUtility.SelectSingleNodeString(oResults, "//RetVal"))	
	sDeploymentType = oUtility.SelectSingleNodeString(oResults, "//DeploymentType")

	
	' If this is a replace, then modifiy the title

	If sDeploymentType = "REPLACE" then
		NormalTitle.style.display = "none"
		ReplaceTitle.style.display = "inline"
	End if


	' Set the background color based on the return code

	If iRetVal = 0 then
		If iErrors > 0 or iWarnings > 0 then
			MyContentArea.style.backgroundColor = "yellow"
		End if
	Else
		MyContentArea.style.backgroundColor = "salmon"
	End if

		
	' Update the dialog

	ErrorCount.InnerText = CStr(iErrors)
	WarningCount.InnerText = CStr(iWarnings)
	optionalWindow1.InnerText = sBuffer
	buttonCancel.disabled = true

End Function
